Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

End oappend v2 #4152

Merged
merged 9 commits into from
Sep 24, 2024
Merged

End oappend v2 #4152

merged 9 commits into from
Sep 24, 2024

Conversation

willmmiles
Copy link
Collaborator

Replacement for #4134 without any usermod changes, which can be considered as a separate PR.

Replace the usage of oppend with Arduino's Print abstraction. This permits efficient use of dynamically allocated memory for returning settings page data, without requiring a single large contiguous allocation up front, or risking smashing the stack.

This change also permits the output generation functions to easily use more sophisticated serialization functions such as printf, reducing the number of required function calls. With this optimization, the overall result is approximate parity in code size to the original implementation.

willmmiles and others added 8 commits September 18, 2024 19:47
Since we validate the file existence ourselves, no need to have
AsyncWebServer do it again.
Useful for checking that I haven't broken anything.
Remove the large stack buffer as we're just going to copy it in to a
heap buffer anyways.  Later we can refine the length estimation or use a
rope-style dynamic data structure like DynamicBufferList.
Use a static Print* to transform old oappend calls to print calls.
Reduce the total number of calls by using printf_P and skipping atoi().
Use named functions to describe what's being printed.
Use a name that makes it a bit clearer what the output is.  The new name
is applied consistently through most uses.
Usermods are not yet updated.
@willmmiles willmmiles mentioned this pull request Sep 19, 2024
@softhack007
Copy link
Collaborator

👍

@blazoncek
Copy link
Collaborator

I am ok to merge this PR.

@willmmiles willmmiles merged commit e789a18 into Aircoookie:0_15 Sep 24, 2024
20 checks passed
@willmmiles willmmiles deleted the end_oappend_v2 branch September 24, 2024 20:56
@netmindz
Copy link
Collaborator

Great work

@FreakyJ
Copy link

FreakyJ commented Sep 28, 2024

Is this a bug or by purpose in xml.cpp? SET_F changed to F
grafik

@willmmiles
Copy link
Collaborator Author

Is this a bug or by purpose in xml.cpp? SET_F changed to F

It's intentional. F() informs print() (via overloading) that the string is stored in PROGMEM on PROGMEM-distinct boards, so it can use an optimized/safer algorithm. SET_F() casts away the distinction, which can result in poor performance or crashes.

@willmmiles willmmiles mentioned this pull request Oct 24, 2024
@willmmiles willmmiles mentioned this pull request Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants